<template>
  <div>
    <a-modal
      :title="option.title || title"
      :visible="visible"
      :confirm-loading="confirmLoading"
      @ok="handleOk"
      @cancel="handleCancel"
    >
      <a-row>
        <a-col :span="5">选择转办人员</a-col>
        <a-col :span="15">
          <StaffSelector v-model="selectStaff" :options="staffSelectorOptions">
          </StaffSelector>
        </a-col>
      </a-row>
    </a-modal>
  </div>
</template>
<script lang="ts">
import { Component, Vue, Prop, Watch, Model } from "vue-property-decorator";
import { Dropdown, Modal, Input, Row, Col } from "@h3/antd-vue";
import "@/config/h3-form";
import StaffSelector from "@cloudpivot/form/src/renderer/components/shared/staff-selector.vue";

@Component({
  name: "AllocateCustomerModal",
  components: {
    ADropdown: Dropdown,
    AModal: Modal,
    AInput: Input,
    ARow: Row,
    ACol: Col,
    StaffSelector: StaffSelector,
  },
})
export default class AllocateCustomerModal extends Vue {
  title: String = "批量转办";
  confirmLoading: Boolean = false;
  visible: Boolean = false;
  option: any = {};

  selectStaff: any = [];
  staffSelectorOptions = {
    isDisplayRoot: true,
    selectOrg: false,
    selectUser: true,
    showModel: true,
    mulpitle: false,
    showSelect: true,
    placeholder: "请选择",
  };

  show(option: any) {
    this.option = option || {};
    this.visible = true;
  }
  handleOk(e) {
    if (this.selectStaff.length <= 0) {
      this.$message.error("请选择转办人员");
      return;
    }
    this.confirmLoading = true;
    setTimeout(() => {
      if (typeof this.option.onOk === "function") {
        this.option.onOk(this.selectStaff);
      }
      this.visible = false;
      this.confirmLoading = false;
    }, 2000);
  }

  handleCancel(e) {
    if (typeof this.option.onCancel === "function") {
      this.option.onCancel();
    }
    this.visible = false;
  }

  get CurrentUser() {
    const ssUser = window.sessionStorage.user;
    if (ssUser) {
      let user = JSON.parse(ssUser);
      return user;
    }
    return null;
  }

  mounted() {
    if (this.CurrentUser) {
      //this.selectValue = [{id: this.CurrentUser.id, name: this.CurrentUser.name, type: 3}];
    }
  }
}
</script>


<style lang="less" scoped>
</style>